<html>
<head>
<title>STRUCT keyword</title>
</head>

<body>
<font color=brown>
<hr>
<h1>
<center>struct keyword in C++</center>
</h1>
<hr>

<p>
The <b>struct</b> keyword was introduced in 'C', its original functionality
is documented
<a href=../../C/SYNTAX/struct.html>here.</a>
<p>

C++ has added two new features to structures.
<ol>
<li>The syntax has been improved slightly so you no longer have to
    mess around with <a href=../../C/SYNTAX/typedef.html>typedef</a> statements.

    <p>
    <center>
    <table border=1 width="80%" bgcolor="ivory">
    <tr><td align=center>
    <h3>ANSI C approch to structures.</h3>
    </tr></td>
    <tr><td>
    <pre>

    typedef struct Person {int age; char *name} Person_t;   

    struct Person FirstMan;
    Person_t      SecondMan;
    </pre>
    </td></tr></table>
    <p>

    <p>
    <table border=1 width="80%" bgcolor="ivory">
    <tr><td align=center>
    <h3>C++ structures.</h3>
    </tr></td>
    <tr><td>
    <pre>

    struct Person {int age; char *name};   

    Person FirstMan;
    Person SecondMan;
    </pre>
    </td></tr></table>
    </center>
    <p>
    
<li>C++ also took the original idea of structures and added the ability to
    associate functions with the data within the structure. This feature
    was wrapped up with the introduction of the
    <a href="class.html">class</a> keyword.
</ol>
<p>
<hr>
<h2>Examples:</h2>
<img src="../../GRAPHICS/computer.gif">
<a href="../EXAMPLES/struct1.cc">Example program.</a>
<p>
<hr>
<h2>See Also:</h2>
<img src="../../GRAPHICS/whiteball.gif" alt="o">
<a href="keywords.html">C++ Keywords</a>
<br>
<img src="../../GRAPHICS/whiteball.gif" alt="o">
<a href="../../C/SYNTAX/keywords.html">C Keywords</a>
<p>

<hr>
<p>
<center>
<table border=2 width="80%" bgcolor="ivory">
<tr align=center>
<td width="25%">
<a href="../cref.html">                  Top</a>
</td><td width="25%">
<a href="../../C/master_index.html">          Master Index</a>
</td><td width="25%">
<a href="keywords.html">                      C++ Keywords</a>
</td><td width="25%">
<a href="../../C/FUNCTIONS/funcref.htm">      Functions</a>
</td>
</tr>
</table>
</center>
<p>
<hr>
<address><a href="../../address.html">Martin Leslie</a> 
12 Nov 98</address><p>
</font>
</body>
</html>
